#include "app_task.h"
#include "state.h"
#include "timer.h"
#include "app.h"
#include "st.h"

static
PT_THREAD(state(PT *pt))
{
	static Timer tmr;
    PT_BEGIN(pt);
    for (;;)
    {
		timer_set(&tmr, 1);
		PT_WAIT_UNTIL(pt, timer_expired(&tmr));

		State_Exec();

		PT_Nop();
    }
    PT_END(pt);
}

PT_THREAD(thread_state(PT *pt))
{
    static PT pt_state;

    PT_BEGIN(pt);
    PT_INIT(&pt_state);

	State_Init();
	State_Change(ST_Default);

	PT_WAIT_THREAD(pt, state(&pt_state));
    PT_YIELD(pt);
    PT_END(pt);
}
